package com.thinkcoder.signutil;

import java.util.Stack;

public class DecimalChange {

    /***
     * 将十进制转换为N进制
     * @param num
     * @param base
     * @return
     */
    public static String getDecimal(Long num,int base){
        StringBuffer sb = new StringBuffer();
        String all="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        //将要转换的进制字母对应表
        String digThs=all.substring(0,base);
        Stack s =new Stack();
        while (num!=0){
            Long bb = num % base;
            s.push(digThs.charAt(bb.intValue()));
            num=num/base;
        }
        while (!s.isEmpty()){
            sb.append(s.pop());
        }
        return sb.toString();
    }
}
